package ace.cmp.util.model.dto;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author caspar
 * @date 2024/7/18 11:22
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TreeNode<T> {

  private T value;
  @Builder.Default
  private List<TreeNode<T>> children = new ArrayList<>();

  public void addChild(TreeNode<T> child) {
    this.children.add(child);
  }

  public void addChildren(Collection<TreeNode<T>> children) {
    this.children.addAll(children);
  }
}
